<template>
  <div>
    <van-nav-bar
      title="修改个人信息"
      right-text="保存"
      left-arrow
      @click-left="onClickLeft"
      @click-right="onClickRight"
    />
    <van-radio-group v-model="radio">
      <van-cell-group>
        <van-cell :title="nan" clickable @click="man">
          <template #right-icon>
            <van-radio name="1" />
          </template>
        </van-cell>
        <van-cell :title="nv" clickable @click="wommon">
          <template #right-icon>
            <van-radio name="2" />
          </template>
        </van-cell>
      </van-cell-group>
    </van-radio-group>
  </div>
</template>

<script>
import { lzuserInfo, lzupdate } from "../../utils/http";
export default {
  name: "",
  components: {},
  props: [],
  data() {
    return {
      radio: "1",
      nan: "男",
      nv: "女",
      sex: "",
    };
  },
  mounted() {
    this.getUserInfo();
  },
  methods: {
    //获取个人信息
    async getUserInfo() {
      const res = await lzuserInfo();
      console.log(res)
      let sex = res.sex;
      if(sex==0){
        this.sex='男'
      }else{
        this.sex='女'
      }
    },
    onClickLeft() {
      this.$router.push("/personal");
    },
  async  onClickRight() {
      let data=this.sex
      const res= await lzupdate(data)
      console.log(res)
       this.getUserInfo();
    },
    man() {
       this.radio = "1";
      this.sex = '男';
      console.log(this.sex);
     
    },
    wommon() {
      this.radio = "2";
      this.sex ='女';
      console.log(this.sex);
    },
  },
  computed: {},
  watch: {},
  created() {},
};
</script>

<style scoped>
</style>
